package org.elsfs.auth.mvc;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.springframework.security.oauth2.core.oidc.OidcScopes;

/**
 * 授权同意说明映射
 *
 * @author zeng
 * @since 0.0.1
 */
public class ScopeWithDescription implements Serializable {

  /** 未知范围-我们无法提供有关此权限的信息，授予此权限时请谨慎. */
  private static final String DEFAULT_DESCRIPTION =
      "UNKNOWN SCOPE - We cannot provide information about this permission, use caution when"
          + " granting this.";

  /** 范围说明 */
  private static final Map<String, String> scopeDescriptions = new HashMap<>();

  static {
    // 此应用程序将能够读取您的个人资料信息。
    scopeDescriptions.put(
        OidcScopes.PROFILE, "This application will be able to read your profile information.");
    //  此应用程序将能够读取您的邮件。
    scopeDescriptions.put("message.read", "This application will be able to read your message.");
    scopeDescriptions.put(
        "message.write",
        "This application will be able to add new messages. It will also be able to edit and delete"
            + " existing messages.");
    scopeDescriptions.put("other.scope", "This is another scope example of a scope description.");
  }

  public final String scope;

  public final String description;

  public ScopeWithDescription(String scope) {
    this.scope = scope;
    this.description = scopeDescriptions.getOrDefault(scope, DEFAULT_DESCRIPTION);
  }
}
